﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace LotteryBO
{
    public class Lottery
    {
        iDAC dac = DACFactory.GetDAC();
        private long _lottery_id = -99;
        private string _company = "";
        private string _lottery_date = "1/1/1800";
        private string _end_date = "1/1/1800";
        private decimal _total_tickets = -99;
        private long _initial_amt = -99;
        private string _winner_id = "";
        private bool _isdeleted = false;

        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long lottery_id
        {
            get
            {
                return _lottery_id;
            }
            set
            {
                _lottery_id = value;
            }
        }
        public string company
        {
            get
            {
                return _company;
            }
            set
            {
                _company = value;
            }
        }
        public string lottery_date
        {
            get
            {
                return _lottery_date;
            }
            set
            {
                _lottery_date = value;
            }
        }
        public string end_date
        {
            get
            {
                return _end_date;
            }
            set
            {
                _end_date = value;
            }
        }
        public decimal total_tickets
        {
            get
            {
                return _total_tickets;
            }
            set
            {
                _total_tickets = value;
            }
        }
        public long initial_amt
        {
            get
            {
                return _initial_amt;
            }
            set
            {
                _initial_amt = value;
            }
        }
        public string winner_id
        {
            get
            {
                return _winner_id;
            }
            set
            {
                _winner_id = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = dac.Parameter("@lottery_id", lottery_id, DbType.Int64, ParameterDirection.Input);
                
               DbParameter dbparam1 = dac.Parameter("@company", company, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = dac.Parameter("@lottery_date",lottery_date , DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = dac.Parameter("@end_date", end_date, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = dac.Parameter("@total_tickets",total_tickets , DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = dac.Parameter("@initial_amt", initial_amt, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam6 = dac.Parameter("@winner_id", winner_id, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = dac.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] {dbparam0,dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6,dbparam7 };
                return dac.Save("Lottery_entry_save", dbparamcall);
            }
            catch(Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long lottery_id, string company, string lottery_date, string end_date, long total_tickets,long initial_amt, string winner_id, bool isdeleted, string andor)
        {
            try
            {
                DbParameter dbparam0 = dac.Parameter("@lottery_id",lottery_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = dac.Parameter("@company", company, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = dac.Parameter("@lottery_date",lottery_date , DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = dac.Parameter("@end_date", end_date, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = dac.Parameter("@total_tickets",total_tickets , DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = dac.Parameter("@initial_amt", initial_amt, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam6 = dac.Parameter("@winner_id", winner_id, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = dac.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam8 = dac.Parameter("@andor", andor, DbType.AnsiString, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6,dbparam7,dbparam8 };
               DataTable dt1= dac.Select("Lottery_entry_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
                

                
                
                

    }
    
}

    

